from socket import *

ADDR = ("127.0.0.1",8888)

def main():
    # 创建tcp套接字
    sock = socket()
    # 与服务端建立连接
    sock.connect(ADDR)
    # 循环收发
    while True:
        msg = input(">>")
        sock.send(msg.encode())
        if not msg or msg == "##":
            break
        data = sock.recv(1024)
        print("From server:",data.decode())
    #关闭连接
    sock.close()

if __name__ == '__main__':
    main()